﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.ServiceProcess;

namespace CamelotSharePointIntegrationService
{
    [RunInstaller(true)]
    public partial class IntegrationServiceInstaller : System.Configuration.Install.Installer
    {
        public IntegrationServiceInstaller()
        {
            InitializeComponent();
        }

        protected override void OnBeforeUninstall(IDictionary savedState)
        {
            base.OnBeforeUninstall(savedState);
            using (var serviceController = new ServiceController(this.serviceInstaller.ServiceName, Environment.MachineName))
            {
                if (serviceController.Status != ServiceControllerStatus.Stopped)
                    serviceController.Stop();
            }
        }
    }
}
